#include "Arduino.h"
#include "console_example.h"
#include "hmi.h"
#include "sd_card.h"
#include "mymqtt.h"
#include "WiFi.h"
#include "HttpsOTAUpdate.h"
#include "https_download.h"
#include "config.h"
#include "task_info.h"
#include "https_download2.h"
#include "system_info.h"
#include "mynetwork.h"
#include "bsp.h"
#include "task_i2c.h"



#define TAG "main"


uint8_t buf[9] = {0xee, 0x61, 0x0a, 0x27, 0xa8, 0xff, 0xfc, 0xff, 0xff};

static char mqtt_https_cert[2048];

void setup(void)
{
	// Serial.begin(115200);
	// Serial.printf("setup------------------------------------------------\n");
    config.begin();
    console_app();
    // HttpsOTA.setInsecure();
    sdcard_init();
    hmi_init();
    // network_init();
    // // attempt to connect to Wifi network:
    // while (WiFi.status() != WL_CONNECTED)
    // {
    //     ESP_LOGI(TAG,".");
    //     delay(1000);
    // }
    // downloader.setEventCallback(downloadEventCallback);
    // downloader.begin();
    // mqtt_app_start();
     task_i2c_start();

    // HttpsOTA.onHttpEvent(HttpEvent);
    // ESP_LOGI(TAG,"Starting OTA");
    // HttpsOTA.begin(url, server_certificate);

    // ESP_LOGI(TAG,"Please Wait it takes some time ...");

//    // 测试 HTTPS 下载，certPem 不为空
//    memset(mqtt_https_cert,0,2048);
//    memcpy(mqtt_https_cert,config.get_https_cert().c_str(),config.get_https_cert().length());
	Serial.printf("------------------------------------------------\n");

}

void loop()
{

    // task_info_print();
    //  downloader.print();
    // SystemInfo::PrintRealTimeStats(3000);
    // SystemInfo::PrintTest();
    delay(1000);
}
